<html>
<head>
<meta http-equiv="Content-Type" type="text/html; charset=UTF-8" />
<script type="text/javascript" lang="Javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js"></script>
<script type="text/javascript" lang="Javascript" src="buffer.js"></script>
<script type="text/javascript" lang="Javascript" src="macho.js"></script>
<script type="text/javascript" lang="Javascript">
var mb = new MachO(MachO.MH_EXECUTABLE, MachO.CPU_TYPE_X86);

with (MachO) {
    var seg = mb.addSegment(SEG_PAGEZERO);
    var seg = mb.addSegment(SEG_TEXT);
    var __text = seg.addSection(SECT_TEXT);
    seg.addSection(SECT_CSTRING);
    seg.addSection(SECT_LITERAL4);
    var __const = seg.addSection(SECT_CONST);
    var seg = mb.addSegment(SEG_DATA);
    var __data = seg.addSection(SECT_DATA);
    seg.addSection(SECT_DYLD);
    seg.addSection(SECT_CFSTRING);
    var seg = mb.addSegment(SEG_OBJC);
    seg.addSection(SECT_OBJC_MESSAGE_REFS);
    seg.addSection(SECT_OBJC_CLASS_REFS);
    var __class = seg.addSection(SECT_OBJC_CLASS);
    seg.addSection(SECT_OBJC_METACLASS);
    seg.addSection(SECT_OBJC_INSTANCE_METHODS);
    seg.addSection(SECT_OBJC_INSTANCE_VARS);
    seg.addSection(SECT_OBJC_MODULES);
    seg.addSection(SECT_OBJC_SYMBOLS);
    seg.addSection(SECT_OBJC_IMAGE_INFO);
    var seg = mb.addSegment(SEG_IMPORT);
    seg.addSection(SECT_POINTERS);
    seg.addSection(SECT_JUMP_TABLE);
    var seg = mb.addSegment(SEG_LINKEDIT);
    mb.setDynamicLinker("/usr/lib/dyld");
    mb.addUnixThread(i386_THREAD_STATE).eip = 0x19b4;
    var libobjc = mb.addDynamicLibrary("/usr/lib/libobjc.A.dylib", '227.0.0', '1.0.0');
    var AppKit = mb.addDynamicLibrary("/System/Library/Frameworks/AppKit.framework/Versions/C/AppKit", '949.46.0', '45.0.0');
    var libgcc = mb.addDynamicLibrary("/usr/lib/libgcc_s.1.dylib", '1.0.0', '1.0.0');
    var libSystem = mb.addDynamicLibrary("/usr/lib/libSystem.B.dylib", '111.1.4', '1.0.0');
    var CoreFoundation = mb.addDynamicLibrary("/System/Library/Frameworks/CoreFoundation.framework/Versions/C/CoreFoundation", '476.18.0', '150.0.0');
    var ApplicationServices = mb.addDynamicLibrary("/System/Library/Frameworks/ApplicationServices.framework/Versions/A/ApplicationServices", '34.0.0', '1.0.0');
    var Foundation = mb.addDynamicLibrary("/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation", '677.24.0', '300.0.0');
    mb.addSymbol("dyld_stub_binding_helper", __text, 0, 0, 0x0);
    mb.addSymbol("__dyld_func_lookup", __text, 0, 0, 0x0);
    mb.addSymbol("-[MyApplicationDelegate applicationDidFinishLaunching:]", __text, 0, 0, 0x0);
    mb.addSymbol("-[MyApplicationDelegate applicationShouldTerminateAfterLastWindowClosed:]", __text, 0, 0, 0x0);
    mb.addSymbol("-[MyApplicationDelegate applicationWillFinishLaunching:]", __text, 0, 0, 0x0);
    mb.addSymbol("-[MyApplicationDelegate dealloc]", __text, 0, 0, 0x0);
    mb.addSymbol("_thePSN.110136", __const, 0, 0, 0x0);
    mb.addSymbol("dyld__mach_header", __data, 0, 0, 0x0);
    mb.addSymbol(".objc_class_name_MyApplicationDelegate", __class, 0, 0, 0x0);
    mb.addSymbol("_NXArgc", __data, N_PEXT, 0, 0x0);
    mb.addSymbol("_NXArgv", __data, N_PEXT, 0, 0x0);
    mb.addSymbol("___progname", __data, N_PEXT, 0, 0x0);
    mb.addSymbol("__mh_execute_header", __text, N_PEXT, REFERENCED_DYNAMICALLY, 0x0);
    mb.addSymbol("_environ", __data, N_PEXT, 0, 0x0);
    mb.addSymbol("_main", __text, N_PEXT, 0, 0x0);
    mb.addSymbol("start", __text, N_PEXT, 0, 0x0);

    mb.addExternalSymbol(".objc_class_name_NSApplication", false, 0, AppKit);
    mb.addExternalSymbol(".objc_class_name_NSAutoreleasePool", false, Foundation);
    mb.addExternalSymbol(".objc_class_name_NSButton", false, AppKit);
    mb.addExternalSymbol(".objc_class_name_NSObject", false, CoreFoundation);
    mb.addExternalSymbol(".objc_class_name_NSWindow", false, AppKit);
    mb.addExternalSymbol("_NSApp", false, AppKit);
    mb.addExternalSymbol("_SetFrontProcess", false, ApplicationServices);
    mb.addExternalSymbol("_TransformProcessType", false, ApplicationServices);
    mb.addExternalSymbol("___CFConstantStringClassReference", false, CoreFoundation);
    mb.addExternalSymbol("_exit", false, libSystem);
    mb.addExternalSymbol("_objc_msgSend", false, libobjc);
    mb.addExternalSymbol("_objc_msgSendSuper", false, libobjc);
}
console.log(mb.serialize());
</script>
</head>
<body>
</body>
</html>
